﻿#if UNITY_EDITOR
using Sirenix.OdinInspector;
using UnityEngine;

namespace Ease.EaseMission.Runtime
{
    public enum ShowDataType
    {
        Stage, //大步骤
        Step, //小步骤
        Data, //行为
    }

    public class MissioInspectorSo : ScriptableObject
    {
        private ShowDataType showDataType = ShowDataType.Stage;

        [ShowInInspector] [ShowIf("showDataType", ShowDataType.Stage)] [HideReferenceObjectPicker]
        private MissionStage stage;

        [ShowInInspector] [ShowIf("showDataType", ShowDataType.Step)] [HideReferenceObjectPicker]
        private MissionStep step;

        [ShowInInspector] [ShowIf("showDataType", ShowDataType.Data)] [HideReferenceObjectPicker]
        private MissionData data;

        public MissionStage Stage
        {
            get => stage;
            set
            {
                stage = value;
                UpdateShowDataType();
            }
        }

        public MissionStep Step
        {
            get => step;
            set
            {
                step = value;
                UpdateShowDataType();
            }
        }

        public MissionData Data
        {
            get => data;
            set
            {
                data = value;
                UpdateShowDataType();
            }
        }

        private void UpdateShowDataType()
        {
            if (data != null)
                showDataType = ShowDataType.Data;
            else if (step != null)
                showDataType = ShowDataType.Step;
            else
                showDataType = ShowDataType.Stage;
        }
    }
}
#endif